package algorithm.sphericharmonics;

import index.SparseMatrix;

import java.util.ArrayList;
import java.util.List;

public class ShapeDescriptor {
	private int min_radiusIndex=Integer.MAX_VALUE; 
	private int max_radiusIndex=Integer.MIN_VALUE; 
	public long objectId; 
	private List<SphereDescriptor> sph=new ArrayList<SphereDescriptor>(); 
	public ShapeDescriptor(){
		
	}
	public SparseMatrix toSparseMatrix(){
		SparseMatrix m=new SparseMatrix(min_radiusIndex,max_radiusIndex);
		m.setObjectId(objectId); 
		//System.out.println(min_radiusIndex+"--->"+max_radiusIndex); 
		for (SphereDescriptor s:sph){
			m.setRow(s.getRadius_index(), s.getL2Normal()); 
		}
		return m; 
	}
	public void addSphereDescriptor(SphereDescriptor sphd){
		if (!sph.contains(sphd)){
			if (min_radiusIndex>sphd.getRadius_index()){
				min_radiusIndex=sphd.getRadius_index();
			}
			if (max_radiusIndex<sphd.getRadius_index()){
				max_radiusIndex=sphd.getRadius_index();
			}
			sph.add(sphd); 
		}
	}
	public void print(){
		for (SphereDescriptor desc:sph){
			desc.print(); 
		}
	}
	public List<SphereDescriptor> getSphereDescriptors(){
		return sph; 
	}
}
